Bump go2rtc to 1.9.12 and go2rtc-client to 0.3.0#156948
Conversation
|
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
| api_paths: tuple[str, ...] = _API_ALLOW_PATHS | ||
| api_ip = _LOCALHOST_IP | ||
| if enable_ui: | ||
| app_modules = _UI_APP_MODULES |
There was a problem hiding this comment.
Alternatively, we could make a new tuple as a local variable here and add the tuple constants into the new tuple and only make the constants contain the separate features instead of making the constants contain all needed features.
|
Test failure unrelated before restarting the failed jobs (now they fail as cache is already deleted) |
There was a problem hiding this comment.
Pull Request Overview
This PR updates go2rtc from version 1.9.11 to 1.9.12 and the go2rtc-client library from 0.2.1 to 0.3.0. The main purpose is to leverage the new API endpoint in go2rtc 1.9.12 that allows fetching activated/supported stream schemes dynamically, replacing the hardcoded list. Additionally, the PR implements security improvements by restricting the go2rtc server to only load necessary modules and API paths.
Key changes:
- Replaces hardcoded
_SUPPORTED_STREAMSlist with dynamic scheme detection viaschemes.list()API - Adds module and API path allowlisting to the go2rtc server configuration for security hardening
- Updates tests to use snapshot testing for configuration validation
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| homeassistant/components/go2rtc/init.py | Removes hardcoded stream schemes list, adds initialize() method to fetch schemes dynamically from API |
| homeassistant/components/go2rtc/server.py | Adds module and API path restrictions to go2rtc config, refactors config generation |
| homeassistant/components/go2rtc/const.py | Updates recommended version to 1.9.12 |
| homeassistant/components/go2rtc/manifest.json | Updates go2rtc-client requirement to 0.3.0 |
| tests/components/go2rtc/test_server.py | Refactors test to use snapshot testing for config validation |
| tests/components/go2rtc/snapshots/test_server.ambr | Adds snapshots for both UI enabled/disabled configurations |
| tests/components/go2rtc/conftest.py | Adds mock for schemes.list() returning supported scheme set |
| Dockerfile | Updates go2rtc binary download URL to version 1.9.12 |
| requirements files | Updates go2rtc-client dependency version across all requirement files |
| script/hassfest/docker/Dockerfile | Updates go2rtc-client version in hassfest Docker image |
| return False | ||
|
|
||
| provider = entry.runtime_data = WebRTCProvider(hass, url, session, client) | ||
| await provider.initialize() |
There was a problem hiding this comment.
The provider.initialize() call is not wrapped in error handling. If the schemes.list() API call fails, it will raise an unhandled exception and cause the config entry setup to fail without a proper error message or ConfigEntryNotReady exception.
Consider wrapping this call in a try-except block similar to the pattern used above for client.validate_server_version():
try:
await provider.initialize()
except Go2RtcClientError as err:
if isinstance(err.__cause__, _RETRYABLE_ERRORS):
raise ConfigEntryNotReady(
f"Could not connect to go2rtc instance on {url}"
) from err
_LOGGER.warning("Could not initialize go2rtc provider on %s (%s)", url, err)
return False
except Exception as err: # noqa: BLE001
_LOGGER.warning("Could not initialize go2rtc provider on %s (%s)", url, err)
return False| await provider.initialize() | |
| try: | |
| await provider.initialize() | |
| except Go2RtcClientError as err: | |
| if isinstance(err.__cause__, _RETRYABLE_ERRORS): | |
| raise ConfigEntryNotReady( | |
| f"Could not connect to go2rtc instance on {url}" | |
| ) from err | |
| _LOGGER.warning("Could not initialize go2rtc provider on %s (%s)", url, err) | |
| return False | |
| except Exception as err: # noqa: BLE001 | |
| _LOGGER.warning("Could not initialize go2rtc provider on %s (%s)", url, err) | |
| return False |
Breaking change
Proposed change
Release client: https://github.com/home-assistant-libs/python-go2rtc-client/releases/tag/0.3.0
Updated go2rtc to the latest version 1.9.12, where we can finally get the activated sources via API. This also required adding support for this new API call in the library,
Enable on the HA-hosted go2rtc only the module we really need
Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: